package com.itheima.auth.intergration.threadlocal;


import com.itheima.auth.intergration.entity.IntegrationAuthenticationEntity;

/**
 * 线程存储当前线程认证信息
 */
public class IntegrationAuthenticationHolder {

    //ThreadLocal中存入用户提交认证信息
    private static ThreadLocal<IntegrationAuthenticationEntity> holder = new ThreadLocal<>();

    /**
     * 存储用户认证信息
     * @param entity
     */
    public static void set(IntegrationAuthenticationEntity entity) {
        holder.set(entity);
    }

    /**
     * 获取用户认证信息
     * @return
     */
    public static IntegrationAuthenticationEntity get() {
        return holder.get();
    }

    /**
     * 清除认证信息
     */
    public static void remove() {
        holder.remove();
    }
}
